package com.ruoyi.web.controller.employ;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WorkEmployPosition;
import com.ruoyi.system.service.IWorkEmployPositionService;

/**
 * 招聘计划Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/system/position")
public class WorkEmployPositionController extends BaseController
{
    @Autowired
    private IWorkEmployPositionService workEmployPositionService;

    /**
     * 查询招聘计划列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WorkEmployPosition workEmployPosition)
    {
        startPage();
        List<WorkEmployPosition> list = workEmployPositionService.selectWorkEmployPositionList(workEmployPosition);
        return getDataTable(list);
    }

    /**
     * 导出招聘计划列表
     */
    @Log(title = "招聘计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkEmployPosition workEmployPosition)
    {
        List<WorkEmployPosition> list = workEmployPositionService.selectWorkEmployPositionList(workEmployPosition);
        ExcelUtil<WorkEmployPosition> util = new ExcelUtil<WorkEmployPosition>(WorkEmployPosition.class);
        util.exportExcel(response, list, "招聘计划数据");
    }

    /**
     * 获取招聘计划详细信息
     */
    @GetMapping(value = "/{positionId}")
    public AjaxResult getInfo(@PathVariable("positionId") Long positionId)
    {
        return success(workEmployPositionService.selectWorkEmployPositionByPositionId(positionId));
    }

    /**
     * 新增招聘计划
     */
    @Log(title = "招聘计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkEmployPosition workEmployPosition)
    {
        return toAjax(workEmployPositionService.insertWorkEmployPosition(workEmployPosition));
    }

    /**
     * 修改招聘计划
     */
    @Log(title = "招聘计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkEmployPosition workEmployPosition)
    {
        return toAjax(workEmployPositionService.updateWorkEmployPosition(workEmployPosition));
    }

    /**
     * 删除招聘计划
     */
    @Log(title = "招聘计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{positionIds}")
    public AjaxResult remove(@PathVariable Long[] positionIds)
    {
        return toAjax(workEmployPositionService.deleteWorkEmployPositionByPositionIds(positionIds));
    }
}
